package com.pattern.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 冯志立
 * @create 2019-10-31 10:22
 */
//composite,可以管理college
public class University extends OrganizationComponent {
    List<OrganizationComponent> organizationComponents =new ArrayList<>();

    //构造器
    public University(String name, String des) {
        super(name, des);
    }

    //重写add
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }

    @Override
    protected void print() {
        //  输出university包含的学院
        System.out.println("========================="+getName()+"==================");
        for (OrganizationComponent organizationComponent:organizationComponents) {
            organizationComponent.print();
        }
    }
}
